package com.atnjupt.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Wizarder
 * @create 2022-03-31 17:22
 * 1.内部捕获用\\分组号
 * 2.外部捕获用$分组号
 */
public class RegDemo3 {
    public static void main(String[] args) {
        String content  = "我....我要....学学学学....编程java!";
        //去除content中的.
        content = content.replaceAll("\\.", "");
        System.out.println(content);
        //内部捕获匹配结巴词语
        String reg = "(.)\\1+";
        Matcher matcher = Pattern.compile(reg).matcher(content);
        while (matcher.find()){
            System.out.println("找到了：" + matcher.group(0));
        }
        //外部捕获单个词语来替换结巴词语
       content =  matcher.replaceAll("$1");
        System.out.println(content);
    }
}
